Hi,
How do i add a drop down box with few pre-populated strings in the same?
I could find list box and drop down menu in the HELP document of Python, but not drop down box.
Please help me in this.
Thanks,
BK
11 24185
Hi,
How do i add a drop down box with few pre-populated strings in the same?
I could find list box and drop down menu in the HELP document of Python, but not drop down box.
Please help me in this.
Thanks,
BK
Tkinter does not have a combobox. If you are using Tkinter, I can supply a module that requires Python Image Library to make a drop-down menu + a text entry + graphics look like a combo box, but it may need some work first. I now use wxPython for GUI.
Tkinter does not have a combobox. If you are using Tkinter, I can supply a module that requires Python Image Library to make a drop-down menu + a text entry + graphics look like a combo box, but it may need some work first. I now use wxPython for GUI.
If that is so, could u please help me in this regard. Are there any pre requisites for the issue?
Thanks,
BK
If that is so, could u please help me in this regard. Are there any pre requisites for the issue?
Thanks,
BK
I am unclear on which issue you want help with.
Hi,
My intention is to have a drop down box (with edit facility) which would have several ip addresses. The user either can select an existing one or else type a new ip.
I could find spinbox option but thats not editable.
So how do i create such a drop down box?
Thanks,
Badri
Hi,
My intention is to have a drop down box (with edit facility) which would have several ip addresses. The user either can select an existing one or else type a new ip.
I could find spinbox option but thats not editable.
So how do i create such a drop down box?
Thanks,
Badri
You still have not said which GUI you are using. If you are using Tkinter, I can supply a class, but it will take me some time to make it work for you.
You still have not said which GUI you are using. If you are using Tkinter, I can supply a class, but it will take me some time to make it work for you.
Yes, I am using Tkinter.
Yes, I am using Tkinter.
Ok, I'll tweek my module to work for you.
Would you include the code so everyone could benefit?
Ok, I'll tweek my module to work for you.
Would you include the code so everyone could benefit?
Yep. I'll get right on it.
Yep. I'll get right on it.
As promised: -
from Tkinter import *
-
-
## I have a working ComboBox which is editable and
-
## has a button around here some where. I'll keep
-
## looking for that. In the mean time, this Entry
-
## subclass shares a StringVar with the menu item
-
## that are created form input list(s) to achive a
-
## simple ChoiceBox.
-
-
class ChoiceBox(Entry):
-
"""ComboBox(parent, itemList=[], *args, kwargs)
-
A simple ChoiceBox with checked menu items
-
itemList may be a mix of list of strings and lists of tuples of (label, list of strings)
-
for one level of sub menu items. *args and kwargs are passed to the Entry widget."""
-
-
def __init__(self, parent, itemList=[], *args, **kwargs):
-
Entry.__init__(self, parent, *args, **kwargs)
-
-
self.pyvar = pyvar = StringVar(self) # this is the sharing mechanism
-
self.config(textvariable=pyvar) # add the StringVar to self.
-
-
self.popup = popup = Menu(self, tearoff=0)
-
self.bind("<Button-1>", self.mousedown, add="+")
-
-
for item in itemList:
-
if type(item) == tuple:
-
submenu = self.GetSubMenu(item[0])
-
for subitem in item[1]:
-
self.AddCBMenuItem(submenu, subitem)
-
else:
-
self.AddCBMenuItem(popup, item)
-
-
def GetSubMenu(self, label):
-
menu = Menu(self, tearoff=0)
-
self.popup.add_cascade(menu=menu, label=label)
-
return menu
-
-
def AddCBMenuItem(self, menu, label):
-
menu.add_checkbutton(label=label,
-
command=self.MenuSelect,
-
variable=self.pyvar, # add the StringVar to a menu.
-
onvalue=label, offvalue='')
-
-
def mousedown(self, event):
-
x = event.x_root - event.x
-
y = event.y_root - event.y
-
self.popup.post(x, y)
-
return 'break'
-
-
def get(self):
-
return self.pyvar.get()
-
-
def clear(self):
-
self.pyvar.set('')
-
-
def MenuSelect(self):
-
pass
-
-
-
-
if __name__ == '__main__':
-
-
-
-
def _test():
-
root = Tk()
-
## cb = ChoiceBox(root, [('test', ['one', 'two', 'three'])])
-
cb = ChoiceBox(root, ['one', 'two', 'three'])
-
cb.pack()
-
root.mainloop()
-
-
_test()
-
Cool code, but I don't see how to enable typing in a new entry...?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PT |
last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From
that 3, 2 are dependant. I can choose one drop down, and the next drop
down should display the dependant values of the first...
|
by: ehm |
last post by:
I am working on creating an editable grid (for use in adding,
deleting, and editing rows back to an Oracle database). I have a JSP
that posts back to a servlet, which in turns posts to a WebLogic...
|
by: Don Wash |
last post by:
Hi There!
I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to
widen the Drop down box's Pull-Down list's width?
I'm not talking about the Drop-down box's width but the box...
|
by: Yoshitha |
last post by:
hi
I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the
items like 50,60,70,80,90,100.
i will...
|
by: Alex Hunsley |
last post by:
Can anyone recommend some code for creating drop-down menus in tkinter?
To be absolutely clear, here's an example of a drop-down:
http://www.google.co.uk/preferences?hl=en
(see the language...
|
by: bruce |
last post by:
Hi...
Never used python, but I have a question regarding Drop Down Menus. Does
Python allow me to create a website, that will permit the user to create
Drop Down menus that can be initiated with...
|
by: callawayglfr |
last post by:
I am building a database in access where I have a drop down box that
relates to a text box, that part I have working but when someone
selects information from the first drop down I need it to limit...
|
by: TycoonUK |
last post by:
Hi,
As I do not have IE7 on my computer, I was wondering if there is a
fault in my CSS Menu when using IE7.
Please can someone look at my site - http://www.worldofmonopoly.co.uk
and tell me...
|
by: penny111 |
last post by:
Hi there,
For my application, i need to have 3 drop down lists
1. drop down list of folder names
2. drop down list of documents in the folder selected
3. drop down list of instances of the...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |